<template>
  <div class="box">
    <el-form ref="form" :model="form" label-width="80px">
      <el-form-item label="账号：">
        <el-input v-model="form.account"></el-input>
      </el-form-item>
      <el-form-item label="密码：">
        <el-input v-model="form.password"></el-input>
      </el-form-item>
      <el-form-item label="状态：">
        <el-switch v-model="form.code"></el-switch>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">确认新增</el-button>
        <el-button>取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
import axios from "../../http/axios";
export default {
  data() {
    return {
      form: {
        account: "",
        password: "",
        code: false,
      },
    };
  },
  methods: {
    async onSubmit() {
      const data = await axios({
        url: "/admins/addAdmins",
        method: "post",
        data: {
          ...this.form,
        },
      });
      console.log(data);
      if (data.data.state) {
        alert("添加成功");
      }
    },
  },
};
</script>
<style scoped>
.box {
  width: 420px;
  height: 500px;
  margin: 0 auto;
}
</style>
